// pages/detail/detail.js
const {detailMusic} = require("../../models/detail")
Page({
  data: {
    value:""
  },

  onLoad: async function (options) {
    console.log(options);
    let id = options.id;
    let res = await detailMusic(id)
    console.log(res);
    this.setData({
      value:res.data.playlist
    })
  },
  onClick(event){
    this.data.value.tracks.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.state = !res.state
      }else{
        res.state = false
      }
    })
    this.setData({
      value:this.data.value
    })
    // console.log(this.data.value);
  },
  toMusic(event){
    let {id,url} = event.currentTarget.dataset;
    console.log(url);
    wx.setStorageSync('imgUrl',url)
    wx.navigateTo({
      url: `/pages/play/play?id=${id}`,
    })
  }
})